package org.jeecg.modules.pinkun.service.impl;

import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import org.jeecg.modules.pinkun.entity.DiyPinkun;
import org.jeecg.modules.pinkun.mapper.DiyPinkunMapper;
import org.jeecg.modules.pinkun.service.IDiyPinkunService;
import org.springframework.stereotype.Service;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;

import java.text.SimpleDateFormat;
import java.util.ArrayList;

/**
 * @Description: 贫困
 * @Author: jeecg-boot
 * @Date:   2021-05-08
 * @Version: V1.0
 */
@Service
public class DiyPinkunServiceImpl extends ServiceImpl<DiyPinkunMapper, DiyPinkun> implements IDiyPinkunService {

    @Override
    public void saveAllInfo(JSONArray form_component_values) {
        DiyPinkun diyPinkun = new DiyPinkun();
        for (int i = 0; i < form_component_values.size(); i++) {
            JSONObject jsonObject = form_component_values.getJSONObject(i);
            String name = jsonObject.getString("name");
            String value = jsonObject.getString("value");
            SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
            try {
                switch (name){
                    case "学号":
                        diyPinkun.setNumber(value);
                        break;
                    case "姓名":
                        diyPinkun.setName(value);
                        break;
                    case "性别":
                        diyPinkun.setSex(value);
                        break;
                    case "出生年月":
                        diyPinkun.setBirthday(sdf.parse(value));
                        break;
                    case "民族":
                        diyPinkun.setNation(value);
                        break;
                    case "身份证账号":
                        diyPinkun.setIdCard(value);
                        break;
                    case "政治面貌":
                        diyPinkun.setZzmm(value);
                        break;
                    case "家庭人口数":
                        diyPinkun.setJtrks(value);
                        break;
                    case "在校月开销":
                        diyPinkun.setZxykx(value);
                        break;
                    case "是否建档立卡":
                        diyPinkun.setSfjdlk(value);
                        break;
                    case "入学前户口（农村/城镇）":
                        diyPinkun.setRxqhk(value);
                        break;
                    case "是否单亲":
                        diyPinkun.setSfdq(value);
                        break;
                    case "是否孤残":
                        diyPinkun.setSfgc(value);
                        break;
                    case "是否烈士或优抚对象子女":
                        diyPinkun.setSflshyfdxzn(value);
                        break;
                    case "家庭人均年收入":
                        diyPinkun.setJtrjnsr(value);
                        break;
                    case "系":
                        diyPinkun.setDepaerment(value);
                        break;
                    case "专业":
                        diyPinkun.setProfessor(value);
                        break;
                    case "邮政编码":
                        diyPinkun.setYzemail(value);
                        break;
                    case "在校联系电话":
                        diyPinkun.setPhoneschool(value);
                        break;
                    case "家庭成员情况":
                        diyPinkun.setJtcyqk(value);
                        break;
                    case "影响家庭经济状况有关信息":
                        diyPinkun.setYxjtjjzkygxx(value);
                        break;
                    case "学生陈述申请认定理由":
                        diyPinkun.setLy(value);
                        break;
                    case "评议小组意见":
                        diyPinkun.setPyxzyjString(value);
                        break;
                    case "本人承诺签字":
                        diyPinkun.setQzString(value);
                        break;
                }

            }catch (Exception e){
                e.printStackTrace();
            }
        }
        // 插入
        System.out.println(diyPinkun);
        baseMapper.insert(diyPinkun);

    }
}
